home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Demos / AppMaker™ 1.5 DEMO / Demo AppMaker™ / Demo AppMaker™.rsrc / TmCT_303_zDoc < prev    next >
Encoding:
Text File  |  1992-04-08  |  3.5 KB  |  163 lines

  1. /* %filename% -- document methods */
  2. /* Created %date% %time% by AppMaker */
  3.  
  4. /*    We recommend that you not modify this module and instead modify        */
  5. /*    its subclass, %Appname%Doc.  The 'z' prefix on this module marks%    %*/
  6. /*    a module which is likely to be regenerated by AppMaker after you    */
  7. /*    make changes to the user interface.  The modules without the 'z'    */
  8. /*    prefix will not be regenerated by AppMaker unless you delete them.    */
  9. /*    Using a separate subclass to override the AppMaker-generated code    */
  10. /*    lets you regenerate code without losing your hand-coded changes.    */ 
  11.  
  12. #include <Commands.h>
  13. #include <Global.h>
  14. #include <CApplication.h>
  15. #include <CBartender.h>
  16. #include <CDataFile.h>
  17. #include <CDesktop.h>
  18. #include <CError.h>
  19. #include <TBUtilities.h>
  20. #include "ResourceDefs.h"
  21. #include "%appname%Data.h"
  22. %if fileExists appname+Doc.c%
  23.     %for each menu gen includeDocDialogs%
  24. %endif%
  25. %for each window gen include%
  26. #include "z%Appname%Doc.h"
  27.  
  28. extern    CApplication    *gApplication;    /* The application */
  29. extern    CBartender        *gBartender;    /* The menu handling object */
  30. extern    CError            *gError;        /* The error handling object */
  31.  
  32. /*----------*/
  33. void    Z%Appname%Doc::I%Appname%Doc%    %(CApplication    *aSupervisor,
  34.                                          Boolean        printable)
  35. {
  36.     inherited::IDocument (aSupervisor, printable);
  37.     itsData = NULL;
  38.  
  39. } /* I%Appname%Doc */
  40.  
  41. /*----------*/
  42. void    Z%Appname%Doc::Dispose        (void)
  43. {
  44.     ForgetObject (itsData);
  45.     itsFile = NULL;        // was disposed by ForgetObject (itsData)
  46.     inherited::Dispose ();
  47.  
  48. } /* Dispose */
  49.  
  50. /*----------*/
  51. void    Z%Appname%Doc::NewFile        (void)
  52. {
  53.     itsData = new C%Appname%Data;
  54.     itsData->I%Appname%Data (this);
  55.  
  56.     BuildWindows ();
  57.  
  58.     if (itsWindow != NULL) {
  59.         itsWindow->Select ();
  60.     }
  61.  
  62. } /* NewFile */
  63.  
  64. /*----------*/
  65. void     Z%Appname%Doc::OpenFile        (SFReply    *macSFReply)
  66. {
  67.     Str63            theName;
  68.  
  69.     itsData = new C%Appname%Data;
  70.     itsData->I%Appname%Data (this);
  71.     itsData->SFSpecify (macSFReply);
  72.     itsData->OpenData (fsRdWrPerm);
  73.     itsFile = itsData;
  74.  
  75.     BuildWindows ();
  76.  
  77.     itsFile->GetName (theName);
  78.     if (itsWindow != NULL) {
  79.         itsWindow->SetTitle (theName);
  80.         itsWindow->Select ();
  81.     }
  82.  
  83. } /* OpenFile */
  84.  
  85. /*----------*/
  86. void    Z%Appname%Doc::BuildWindows        (void)
  87. {
  88.     CWindow            *mainWindow;
  89.     CDirector        *subWindow;
  90.  
  91.     %for each window gen create%
  92.  
  93. } /* BuildWindows */
  94.  
  95. /*----------*/
  96. Boolean    Z%Appname%Doc::DoSave        (void)
  97. {
  98.     if (itsFile == NULL) {
  99.         return (DoSaveFileAs ());
  100.     } else {
  101.         if (itsData->Save ()) {
  102.             dirty = FALSE;
  103.             return (TRUE);
  104.         } else {
  105.             return (FALSE);
  106.         }
  107.     }
  108. } /* DoSave */
  109.  
  110. /*----------*/
  111. Boolean    Z%Appname%Doc::DoSaveAs        (SFReply    *macSFReply)
  112. {
  113.     if (itsData->SaveAs (macSFReply)) {
  114.         itsFile = itsData;
  115.         if (itsWindow != NULL) {
  116.             itsWindow->SetTitle (macSFReply->fName);
  117.         }
  118.         dirty = FALSE;
  119.         return (TRUE);
  120.     } else {
  121.         return (FALSE);
  122.     }
  123.  
  124. } /* DoSaveAs */
  125.  
  126. /*----------*/
  127. void    Z%Appname%Doc::DoRevert        (void)
  128. {
  129.     itsData->Revert ();
  130.     dirty = FALSE;
  131.  
  132. } /* DoRevert */
  133.  
  134. %if fileExists appname+Doc.c%
  135.     /*----------*/
  136.     /* This code should be in %Appname%Doc.c rather than in this file. */
  137.     /* AppMaker generated it here because %Appname%Doc.c already existed. */
  138.     /* AppMaker doesn't overwrite an existing non-Z file because it */
  139.     /* might have lots of user hand-written code. */
  140.     /*----------*/
  141.     void    Z%Appname%Doc::UpdateMenus        (void)
  142.     {
  143.         inherited::UpdateMenus ();
  144.         %for each menu gen updateDocMenus%
  145.     
  146.     } /* UpdateMenus */
  147.  
  148.     /*----------*/
  149.     void    Z%Appname%Doc::DoCommand        (long        theCommand)
  150.     {
  151.         switch (theCommand) {
  152.             %for each menu gen handleDocItems%
  153.     
  154.             default:
  155.                     inherited::DoCommand (theCommand);
  156.                 break;
  157.         } /* switch */
  158.     
  159.     } /* DoCommand */
  160.  
  161. %endif%
  162. /* %filename% */
  163.